package cn.tj.service.impl;

import cn.tj.entity.PageBean;
import cn.tj.entity.Register;
import cn.tj.entity.User;
import cn.tj.mapper.RegisterMapper;
import cn.tj.service.RegisterService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;

    @Override
    public PageBean listByPage(Integer currentPage, Integer pageSize, String account, Date minTime, Date maxTime) {
        PageBean<Object> pb = new PageBean<>();

        PageHelper.startPage(currentPage,pageSize);
        List<Register> rList = registerMapper.listByPage(account,minTime,maxTime);
        Page p=(Page) rList;

        pb.setItems(p.getResult());
        pb.setTotal(p.getTotal());
        return pb;
    }

    @Override
    public void check(User user) {
        registerMapper.check(user);
        registerMapper.delete(user.getId());
    }

    @Override
    public void delete(Integer id) {
        registerMapper.delete(id);
    }
}
